package pojo;
import dao.Paper;
public class TestPager implements Paper {

    private int charPerLine = 16;
    private int LinePerPage = 10;
    private String couten = "";
    private int posX = 0;
    private int posY = 0;
    public int posP = 1;

    public int getCharPerLine() {
        return charPerLine;
    }

    public void setCharPerLine(int charPerLine) {
        this.charPerLine = charPerLine;
    }

    public int getLinePerPage() {
        return LinePerPage;
    }

    @Override
    public void putlnChar(char c) {
        couten += c;
        ++posX;
        if (posX == charPerLine) {
            couten = couten + c;
            posY = 0;
            ++posP;
        }
    }

    public int setContent(int charPerLine) {
        this.charPerLine = charPerLine;
        return charPerLine;
    }

    public void setLinePerPage(int LinePerPage) {
        this.LinePerPage = LinePerPage;
    }

    @Override
    public String getContent() {
        String ret = this.couten;
        if (!(posX == 0 && posY == 0)) {
            int count = LinePerPage - posY;
            for (int i = 0; i < count; i++) {
                ret += Paper.newline;
            }
            ret += "==第" + posP + "页==";
        }
        return ret;
    }

}
